package com.an.collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@SuppressWarnings({"all"})

public class IteratorTest {
    public static void main(String[] args) {
        Collection col=new ArrayList();
        col.add(new Book("红楼梦",38.9));
        col.add(new Book("金瓶梅",28.9));
        col.add(new Book("西游记",48.9));
        col.add(new Book("新三国",58.9));
        col.add("mack");
        Iterator integer=col.iterator();
        while (integer.hasNext()) {
            Object next = integer.next();
            System.out.println(next);
        }

    }
}
@SuppressWarnings({"all"})

class Book{
    private String name;
    private double preice;

    public Book(String name, double preice) {
        this.name = name;
        this.preice = preice;
    }

    @Override
    public String toString() {
        return "Book{" +
                "name='" + name + '\'' +
                ", preice=" + preice +
                '}';
    }
}